#include<stdio.h>
#include<stdlib.h>
#include<windows.h>

/*
	Author:	H组全体成员
	Date:	2020-10-15
*/

int main()
{
	int x = 0;

	int y = 5;

	int velocity_x = 1;

	int velocity_y = 1;
	int left = 0;
	int right = 20;
	int top = 0;
	int bottom = 10;

	char outputChar = 0;

	while (1)
	{
		x = x + velocity_x;
		y = y + velocity_y;

		system("cls");
		for (int mapY = 0; mapY <= bottom; ++mapY) {
			for (int mapX = 0; mapX <= right; ++mapX) {
				if (mapX == 0 || mapX == right) {
					outputChar = mapY == 0 ? ' ' : '|';
				}
				else if (mapY == 0 || mapY == bottom) {
					outputChar = '_';
				}
				else if (mapX == x && mapY == y) {
					outputChar = 'o';
				}
				else {
					outputChar = ' ';
				}
				putchar(outputChar);
			}
			putchar('\n');
		}
		Sleep(50);

		if ((x == left) || (x == right))
			velocity_x = -velocity_x;
		if ((y == top) || (y == bottom))
			velocity_y = -velocity_y;
	}
	return 0;
}